/**
 * Created by mac on 16/5/7.
 */

function onRequest(request, response, modules) {
    var httptype = modules.oHttptype;　//获取调用云端逻辑的是post或者get方式
    var mPara
    if('get' == httptype){
        mPara = request.query
    }else if('post' == httptype){
        mPara = request.body
    }
    mPara.table = mPara.table || 'Lost'

    var db = modules.oData;
    db.findOne({
        "table":  mPara.table ,
        "objectId":  mPara.id
    },function(err,data){
        if(err){
            response.send('code'+err.code+',msg:'+ err.error);
        }else{
            response.send(data)
        }
    });
}

// 传入表名称 获得记录数
function onRequest(request, response, modules) {
    var httptype = modules.oHttptype;　//获取调用云端逻辑的是post或者get方式
    var mPara
    if('get' == httptype){
        mPara = request.query
    }else if('post' == httptype){
        mPara = request.body
    }
    mPara.table = mPara.table || 'Lost'

    var db = modules.oData;
    db.find({
        "table":mPara.table,
        "limit":0,
        "count":1
    },function(err,data){
        resultObject= JSON.parse(data);
        count=resultObject.count;
        response.send("表记录数:"+count);

    });
}

//获得数据库中的文件
function onRequest(request, response, modules) {
    var httptype = modules.oHttptype;　//获取调用云端逻辑的是post或者get方式
    var mPara
    if('get' == httptype){
        mPara = request.query
    }else if('post' == httptype){
        mPara = request.body
    }
    mPara.table = mPara.table || 'Lost'

    var db = modules.oData;
    db.find({
        "table":mPara.table,
        "objectId":  mPara.id
    },function(err,data){
        if(err){
            response.send('code'+err.code+',msg:'+ err.error);
        }else{
            response.send(data)
        }
    });
}




